<?php
include("admin_check.php");
include_once("../function.php");
include_once("../class/member_class.php");
include_once("../class/bonus_class.php");
include_once("../class/ulevel_class.php");
set_time_limit(0);
ignore_user_abort(true);
session_start();
header("Content-Type: text/html;charset=utf-8");
checkqx(1,1);?>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link href="css/table.css" rel="stylesheet" type="text/css">
<link href="css/style.css" rel="stylesheet" type="text/css">
<script src="../js/calendar.js"></script>
    <link href="../layui-master/dist/css/layui.css" rel="stylesheet" type="text/css">
    <script src="../layui-master/dist/layui.js"></script>
<title>奖励会员</title>
<SCRIPT LANGUAGE=javascript>
<!--
function SelectAll() {
	for (var i=0;i<document.form1.UID.length;i++) {
		var e=document.form1.UID[i];
		e.checked=!e.checked;
	}
}
-->
</script>
</head>
<body>
<?php 
$bonus_cl = new bonus_class();
if($_POST['tijiao']){
	$money = $_POST['money'];
	$nickname = $_POST['nickname'];
	if($money>0){
		$sql = "select * from member where nickname= '".$nickname."'";
		$row = getOne($sql);
		if($row['id']==0 || $row['id']==null){
			echo "<script language=javascript>alert('会员不存在.');window.location.href='?'</script>";
		}
		edit_sql("update `member` set mey=mey+".$money.",maxmey = maxmey+".$money." where id=".$row['id']."");
		$beizhu=$money."元特别贡献奖";
		$bonus_cl->bonus_laiyuan($row['id'],$row['nickname'],0,"-",12,$money,$beizhu);
                    $bonus_update['uid']=$row['id'];
					$bonus_update['b0']=$money;
					$bonus_update['b1']=0;
					$bonus_update['b2']=0;
					$bonus_update['b3']=0;
					$bonus_update['b4']=0;
					$bonus_update['b5']=0;
					$bonus_update['b6']=0;
					$bonus_update['b7']=0;
					$bonus_update['b8']=0;
					$bonus_update['b9']=0;
					$bonus_update['b10']=0;
					$bonus_update['b11']=0;
					$bonus_update['b12']=$money;
					$bonus_update['b13']=0;
				
		 $bonus_cl->bonus_insert(1,$bonus_update);;
		echo "<script language=javascript>alert('发放完成.');</script>";
	}else{
		echo "<script language=javascript>alert('请正确填写.');</script>";
	}
}
if($_POST['tijiao2']){
	$money = $_POST['money2'];
	if($money>0){
		edit_sql("update `member` set mey=mey+".$money.",maxmey = maxmey+".$money.",b13=b13+".$money."");
		$sql2 = "select * from member";
		if($query = mysql_query($sql2)){
		while ($row=mysql_fetch_array($query)){		
		
		$beizhu=$money."元感恩奖";
		$bonus_cl->bonus_laiyuan($row['id'],$row['nickname'],0,"-",13,$money,$beizhu);		
		            $bonus_update['uid']=$row['id'];
					$bonus_update['b0']=$money;
					$bonus_update['b1']=0;
					$bonus_update['b2']=0;
					$bonus_update['b3']=0;
					$bonus_update['b4']=0;
					$bonus_update['b5']=0;
					$bonus_update['b6']=0;
					$bonus_update['b7']=0;
					$bonus_update['b8']=0;
					$bonus_update['b9']=0;
					$bonus_update['b10']=0;
					$bonus_update['b11']=0;
					$bonus_update['b12']=0;
					$bonus_update['b13']=$money;
		$bonus_cl->bonus_insert(1,$bonus_update);
		echo $sql;
		//break;
	}
	//$bonus_cl->b0bonus();
	
	echo "<script language=javascript>alert('发放完成.');</script>";
	}	
}else{
		echo "<script language=javascript>alert('请正确填写.');window.location.href='?'</script>";
	}
}
?>
<form name="form1" method="post" action="?">
<table width="100%" cellpadding="3" cellspacing="1" border="0" align="center" class="layui-table" lay-skin="line">
     </form>
      <tr>
        <td height="20" colspan="10" align="center">奖励达标会员</td>
      </tr>
      <tr style="display:none">
        <td height="20" colspan="10" align="center"><font color=red>说明:1、在后台激活会员的，该会员所属的服务中心或者县区店不会扣除激活电子币，同样报单服务费或者店补也拿不到。2、空单会员不算业绩，但是空单伞下有实单业绩，空单可以拿到奖金。(以上操作仅限后台操作，会员区专卖店或者服务中心激活不存在这种情况)</font></td>
      </tr>
      <tr>
      <!-- 	<td height="21" align="center"><input type="checkbox" name="checkbox" value="checkbox" onClick="javascript:SelectAll()"></td> -->
        <td align="center">会员编号</td>
       <!--  <td align="center">会员名称</td> -->
       <td align="center"><INPUT type="text" name="nickname"></td>
        </tr>
     	 <tr>
	         <td align="center">特别贡献奖</td>
	      <!-- <td align="center"><INPUT type="text" name="username"></td> -->
	        <td align="center"><INPUT type="text" name="money"></td>
       </tr>
       <tr>
	        <td align="center" colspan="2"><INPUT type="submit" name="tijiao" value="发放"></td>
       </tr>
       	 <tr>
	         <td align="center">感恩奖</td>
	      <!-- <td align="center"><INPUT type="text" name="username"></td> -->
	        <td align="center"><INPUT type="text" name="money2"></td>
       </tr>
       <tr>
	        <td align="center" colspan="2"><INPUT type="submit" name="tijiao2" value="发放"></td>
       </tr>
      <tr>
        <td height="21" colspan="10" align="right">
        <table width="100%" border="0">
          <tr>
           <!-- <td align="left"><input name="button" type="submit" class="layui-btn layui-btn-small" id="button" value="激活会员" onClick="{if(confirm('您确定要激活该会员吗?')){this.document.selform.submit();return true;}return false;}">
            <input name="button2" type="submit" class="layui-btn layui-btn-small" id="button2" value="团队领导" onClick="{if(confirm('您确定要将该会员设置为团队领导吗?')){this.document.selform.submit();return true;}return false;}">-->
            <!--<input name="button3" type="submit" class="layui-btn layui-btn-small" id="button3" value="空单会员" onClick="{if(confirm('您确定要将该会员设置为空单会员吗?')){this.document.selform.submit();return true;}return false;}">
            <input name="button4" type="submit" class="layui-btn layui-btn-radius layui-btn-danger" id="button4" value="删除会员" onClick="{if(confirm('您确定要删除该会员吗?')){this.document.selform.submit();return true;}return false;}"></td>-->
            <td align="right"><?php echo fenye($p,$pagesize,$sum,$total,$cx)?></td>
          </tr>
        </table></td>
      </tr>
    </table>
    </form>
</body>
</html>